ccR.Mage.Frost = {
	Ice_Block =
	function(health) 
		if health == nil then health = 10 end
		if ccR.Spell.Is.Ready(ICE_BLOCK) 
		and ccR.Player.Health() <= 10
		and not ccR.Player.Has.Debuff(HYPOTHERMIA) 
		then 
			ccR.StopCasting()
			ccR.Cast.Spell(ICE_BLOCK) 
		end
	end,
	Frozen_Fingers = 
	function(count)
		if count == nil then count = 1 end
		if ccR.Player.Buff.Stacks(FINGERS_OF_FROST) >= count then
			ccR.StopCasting({ BLIZZARD, FROSTBOLT })
			if ccR.Spell.CanAttack(ICE_LANCE) then ccR.Cast.AF.Attack(ICE_LANCE) end
		end
	end,
	Ice_Lance_Frozen = 
	function()
		if ccR.Target.Is.Frozen() then
			ccR.StopCasting({ BLIZZARD, FROSTBOLT })
			if ccR.Spell.CanAttack(ICE_LANCE) then ccR.Cast.AF.Attack(ICE_LANCE) end
		else
			for x = 1, # ccR_Enemies_In_Combat do
				local vUnit = ccR_Enemies_In_Combat[x]
				if ccR.Unit.Is.Frozen(vUnit) then
					ccR.StopCasting({ BLIZZARD, FROSTBOLT })
					if ccR.Spell.CanAttack(ICE_LANCE, vUnit) then ccR.Cast.AF.Attack(ICE_LANCE, vUnit) return end
				end
			end
		end
	end,
	Ice_Lance = 
	function()
		if ccR.Spell.Can.Attack(ICE_LANCE) then ccR.Cast.AF.Attack(ICE_LANCE) end
	end,
	Summon_Pet = 
	function()
		if not ccR.Pet.IsAlive() 
		and ccR.Spell.Is.Ready(SUMMON_WATER_ELEMENTAL) 
		and (not ccR.Player.Is.Moving() or ccR.Player.Has.Buff(ICE_FLOES)) 
		then 
			ccR.Cast.Spell(SUMMON_WATER_ELEMENTAL) 
		end
	end,
	Cone_of_Cold =
	function()
		if ccR.Var("Use_Cone_of_Cold") 
		and (not ccR.Var("Use_Cone_of_Cold_Only_Solo") or (ccR.Var("Use_Cone_of_Cold_Only_Solo") and ccR.Player.Is.Solo()))
		then
			if ccR.Player.Has.Spell(CONE_OF_COLD) 
			and ccR.Player.Count(8) > 0 
			and ccR.Spell.Is.Ready(CONE_OF_COLD) 
			and #ccR_Enemies_Within_8 > 0 
			then
				ccR.Cast.AF.Spell(CONE_OF_COLD, ccR_Enemies_Within_8[1])
			end
		end
	end,
	Icy_Veins = 
	function()
		if ccR.Player.Has.Spell(ICY_VEINS) 
		and ccR.Spell.Is.Ready(ICY_VEINS) 
		then 
			ccR.Cast.Spell(ICY_VEINS) 
		end		
	end,
	Frozen_Orb =
	function()
		if ccR.Player.Has.Spell(FROZEN_ORB) 
		and ccR.Spell.Is.Ready(FROZEN_ORB) 
		and ccR.Target.Is.Attackable()
		then 
			ccR.StopCasting(FROSTBOLT, 0.5)
			ccR.Cast.AF.Spell(FROZEN_ORB, "target") 
		end
	end,
	Deep_Freeze =
	function()
		if ccR.Player.Has.Spell(DEEP_FREEZE,true)
		and ccR.Spell.Is.Ready(DEEP_FREEZE)
		then
			if ccR.Target.Is.Attackable()
			and ccR.Target.Is.Frozen()
			then
				if ccR.Spell.CanAttack(DEEP_FREEZE) then ccR.Cast.Attack(DEEP_FREEZE) end
			else
				if #ccR_Enemies_In_Combat > 0 then
					for x = 1, #ccR_Enemies_In_Combat do
						local vUnit = ccR_Enemies_In_Combat[x]
						if ccR.Unit.Exists(vUnit)
						and ccR.Unit.Is.Attackable(vUnit)
						and not ccR.Unit.Is.Boss(vUnit)
						and not ccR.Unit.Is.Frozen(vUnit)
						then
							ccR.Cast.Attack(DEEP_FREEZE, vUnit) 
						end
					end
				end
			end
		end
	end,
	Frostfire_Bolt =
	function()
		if ccR.Player.Has.Spell(FROSTFIRE_BOLT) 
		and ccR.Player.Has.Buff(BRAIN_FREEZE) 
		then 
			ccR.StopCasting(0.5)
			if ccR.Spell.CanAttack(FROSTFIRE_BOLT) then ccR.Cast.AF.Attack(FROSTFIRE_BOLT) end
		end
	end,
	Freeze =
	function()
		if ccR.Pet.IsAlive()
		and ccR.Target.Is.Attackable()
		and ccR.Pet.Distance("target") <= 44 
		and ccR.Unit.Is.InLineOfSight("pet", "target") 
		then 
			if ccR.Player.Has.Spell(WATER_JET)
			and ccR.Spell.Is.Ready(WATER_JET)
			and not ccR.Unit.Is.ChannelingSpell("pet", WATER_JET)
			and (ccR.Target.Is.Boss() or ccR.Target.Count(8) == 1)
			then
				ccR.Cast.Attack(WATER_JET)
			end

			if ccR.Player.Has.Spell(FREEZE) 
			and ccR.Spell.Is.Ready(FREEZE) 
			and not ccR.Target.Is.Frozen() 
			and not ccR.Target.Is.Boss()
			then
				ccR.Cast.Spell(FREEZE) 
				if SpellIsTargeting() then CastAtPosition(ObjectPosition("target")) end 
			end
		end
	end,
	Frostbolt =
	function()
		if ccR.Spell.CanAttack(FROSTBOLT) 
		and ccR.Player.Is.Facing("target") 
		and (not ccR.Player.Is.Moving() or ccR.Player.Has.Buff(ICE_FLOES))
		then 
			ccR.Cast.Attack(FROSTBOLT) 
		end
	end,
	Blizzard =
	function()
		if ccR.Player.Has.Spell(BLIZZARD) 
		and ccR.Spell.Is.Ready(BLIZZARD) 
		and (not ccR.Player.Is.Moving() or ccR.Player.Has.Buff(ICE_FLOES))
		then 
			ccR.Cast.AoE(BLIZZARD, "target", 35, 12) 
		end
	end,
	Cancel_Blizzard =
	function()
		if (
				(ccR.Player.Has.Buff(FINGERS_OF_FROST))
				or
				(ccR.Player.Has.Spell(FROZEN_ORB) and ccR.Spell.CooldownTime(FROZEN_ORB) == 0)
				or
				(ccR.Player.Has.Spell(COMET_STORM) and ccR.Spell.CooldownTime(COMET_STORM) == 0)
			)
		and ccR.Player.Is.ChannelingSpell(BLIZZARD) 
		then
			SpellStopCasting() 
		end
	end,
}
setmetatable(ccR.Mage.Frost, ccR.Mage)